import { defineStore } from 'pinia'
import { getToken, removeToken, setToken } from '../../utils/token-utils'
import { getHistoryListApi, getPracticeApi,getHistorySearchApi,getDeleteApi,getCollectApi,getHuanCunApi } from '../../api/practive'

const useUserInfoStore = defineStore('userInfo', {
	state: () => ({
		//浏览记录中是数组
		content: [],
		//练习室数组,4个都用
		practiceList: [],
		
		
	}),
	actions: {
		async getHistoryList() {
			let result = await getHistoryListApi();
			this.content = result.content;
			
		},
		//获取练习室数据
		async getPractice(myListCategory?: string){
			let result = await getPracticeApi(myListCategory)
			this.practiceList = result.content;
			
		},
		//获取点击搜索
		async getHistorySearch(keyword:string) {
			let result = await getHistorySearchApi(keyword);
		
			this.content = result.content;
			
		},
		//获取历史删除确定按钮
		async getDelete(id:any) {
			let result = await getDeleteApi(id);
		
			this.content = result.content;
			
		},
		//获取收藏数据
		async getCollect() {
			let result = await getCollectApi();
			this.content = result.content;
			
		},
		//获取缓存数据
		async getHuanCun() {
			let result = await getHuanCunApi();
			this.content = result.content;
			
		},

	},
})
export default useUserInfoStore
